package com.lywz.web.interceptor;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.ServletActionContext;

import com.lywz.core.web.WebConstants;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;

public class GlobalInterceptor extends AbstractInterceptor {

    private static final long serialVersionUID = 8668948350950469691L;

    @Override
    public String intercept(ActionInvocation inv) throws Exception {
        HttpServletRequest request = ServletActionContext.getRequest();
        
        String path = request.getContextPath();
        String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";

        
        request.setAttribute("staticWebsite", WebConstants.staticWebsite);
        request.setAttribute("website", basePath); // WebConstants.website);
        request.setAttribute("webFullName", WebConstants.webFullName);
        request.setAttribute("webName", WebConstants.webName);
        request.setAttribute("webTitle", WebConstants.webTitle);
        request.setAttribute("staticWebsite", basePath + "resource/"); //WebConstants.staticWebsite);

        return inv.invoke();
    }

}
